package com.own.business.system.user.common.constant;

import com.own.component.common.util.list.ListUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * ConstantPermission
 *
 * @author chenxueli
 * @date 2021-09-13 14:02:00
 */
public final class ConstantPermission {

    public static final List<String> PERMISSION_LIST = new ArrayList<>();
    public static final String ADD = "添加";
    public static final String BATCH_ADD = "批量添加";
    public static final String UPDATE = "修改";
    public static final String BATCH_UPDATE = "批量修改";
    public static final String DELETE = "删除";
    public static final String BATCH_DELETE = "批量删除";
    public static final String EXPORT = "导出";
    public static final String IMPORT = "导入";
    public static final String DETAIL = "详情";
    public static final String SEARCH_PERSONAL = "查个人";
    public static final String SEARCH_ORGANIZATION = "查组织";
    public static final String SEARCH_ALL = "查全部";
    private static final List<String> SORT_PERMISSION_LIST = new ArrayList<>();

    static {
        PERMISSION_LIST.add(ADD);
        PERMISSION_LIST.add(BATCH_ADD);
        PERMISSION_LIST.add(UPDATE);
        PERMISSION_LIST.add(BATCH_UPDATE);
        PERMISSION_LIST.add(DELETE);
        PERMISSION_LIST.add(BATCH_DELETE);
        PERMISSION_LIST.add(SEARCH_PERSONAL);
        PERMISSION_LIST.add(SEARCH_ORGANIZATION);
        PERMISSION_LIST.add(SEARCH_ALL);
        PERMISSION_LIST.add(EXPORT);
        PERMISSION_LIST.add(IMPORT);
        PERMISSION_LIST.add(DETAIL);

        // 标准排序的权限列表
        SORT_PERMISSION_LIST.add(SEARCH_PERSONAL);
        SORT_PERMISSION_LIST.add(SEARCH_ORGANIZATION);
        SORT_PERMISSION_LIST.add(SEARCH_ALL);
        SORT_PERMISSION_LIST.add(DETAIL);
        SORT_PERMISSION_LIST.add(ADD);
        SORT_PERMISSION_LIST.add(BATCH_ADD);
        SORT_PERMISSION_LIST.add(UPDATE);
        SORT_PERMISSION_LIST.add(BATCH_UPDATE);
        SORT_PERMISSION_LIST.add(DELETE);
        SORT_PERMISSION_LIST.add(BATCH_DELETE);
        SORT_PERMISSION_LIST.add(EXPORT);
        SORT_PERMISSION_LIST.add(IMPORT);
    }

    /**
     * 对数组进行排序
     *
     * @param list 待排序的数据
     */
    public static void sort(List<String> list) {
        ListUtil.Sort.sort(list, SORT_PERMISSION_LIST, String::valueOf);
    }

}
